{
  //定义一个类型的别名  重点
  type n = number;
  type s = string;

  let str: s = '123';

  interface User{
    username: string;
    password: string;
    email?: string;
  }
  //定义一个类型
  type Users = User[];
  let result: Users = [{username: 'xx', password: 'xxx'}, {username: 'yyy', password: 'zzz'}];

  //使用 type 定义一个接口
  type Book = {
    id: number;
    title: string;
    price: number;
  };

  let b: Book = {
    id: 10,
    title: '郭敬明',
    price: 15.9
  };

  //获取 b 变量的类型  这里的 typeof 是 TS 的 typeof, 不是 js 的
  type result = typeof b;

  //获取接口键名的联合类型  key 键  of 属于 
  // type keys = keyof User;             'username' | 'password'
  function getUserValue(obj: User, key: keyof User){
    return obj[key];
  }

  let user: User = {
    username: 'xxx',
    password: 'xxx',
    email: 'xxxx'
  }

  getUserValue(user, 'username');


  //声明一个函数
  function test(a: number, b: number){
    return a + b;
  }

  type fnType = typeof test;

  //获取函数返回值类型
  type retType = ReturnType<typeof test>;
  //获取函数参数的类型
  type paramType = Parameters<typeof test>;


  //定义一个接口
  interface Shoe{
    brand: string;
    color: string;
    price: number;
  }

  let t: Shoe['color'];


}